package com.dz51.core.validate.validator.strategy;

import javax.servlet.http.HttpServletRequest;

import com.dz51.core.utils.DbcSbcUtils;
import com.dz51.core.validate.annotation.ParamValidater;
import com.dz51.core.validate.util.ValidateResultBulider;
import com.dz51.core.validate.vo.ValidateResult;

/**
 * 全角字符长度验证
 * 
 */
public class MaxFullLenValidator extends ValidateModel {

	@Override
	public ValidateResult validate(HttpServletRequest request, ParamValidater paramValidater) {
		if (request == null || paramValidater.name() == null) {
			return ValidateResultBulider.createSuccessResult(request);
		}
		String param = request.getParameter(paramValidater.name());
		if (param == null) {
			return ValidateResultBulider.createSuccessResult(request);
		}
		if (DbcSbcUtils.getLength(param) > paramValidater.maxLen()) {
			return ValidateResultBulider.createNoReasonFailResult(request);
		}
		return ValidateResultBulider.createSuccessResult(request);

	}

}
